package com.yufubao.api.controller.common;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import com.yufubao.framework.annotation.SystemLog;
import com.yufubao.framework.result.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.yufubao.framework.constant.SystemConstants.ADMIN;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2024/8/22 17:09
 */
@RestController
@RequestMapping("/applet/management")
@Slf4j
public class TestController {

    @GetMapping("t1")
    @SystemLog(info = "ssss")
    @SaCheckRole(ADMIN)
    public ResponseResult test() {
        System.out.println("登录成功，id：" + StpUtil.getLoginIdAsLong());
        System.out.println("登录成功，角色：" + StpUtil.getRoleList());
        System.out.println("登录成功，info：" + StpUtil.getSession().get(SaSession.USER));
        log.info("test");
        return ResponseResult.okResult(new String("11111"));
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        System.out.println(bCryptPasswordEncoder.encode("yufubao123"));
    }
}
